import 'LoginContractPresenter.dart';
import 'LoginContractView.dart';
import 'LoginModel.dart';

class LoginPresenter implements LoginContractPresenter {
  final LoginContractView _view;
  final LoginModel _model;

  LoginPresenter(this._view, this._model);

  @override
  void login(String username, String password) async {
    try {
      bool isAuthenticated = await _model.authenticate(username, password);
      if (isAuthenticated) {
        _view.onLoginSuccess('登录成功');
      }
    } catch (e) {
      _view.onLoginError(e.toString());
    }
  }
}